package cn.tedu.boot12.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@Controller
public class HelloController {
    @RequestMapping("/hello")
    public void hello(HttpServletResponse response) throws IOException {
        System.out.println("接受到了请求!!!");
        //设置响应类型 告诉浏览器响应的内容是什么
        response.setContentType("text/html;charset=utf8");
        //获取输出对象 异常抛出
        PrintWriter pw=response.getWriter();
        //输出数据
        pw.print("<h1>我是服务器 我接受到了请求</h1>");
        //关闭资源
        pw.close();
    }
}
